<?

// $Id: Clazz.php,v 1.1.1.1 2005/03/03 04:53:22 icer Exp $

/*
 *
 * $Clazz.php 2004-3-8
 * @author Binzy Wu
 * Email: Binzy at JustDN dot Com
 * Blog: http://0926.net
 * 
 * ChangeLog,
 * 
 *
 * @package izz.proxy
 *
 * */
define('CRLF', "\n");
define('TAB', "\t");

class Clazz
{

	function instance(&$handler, $objType, $dynamicTypeName, $methods)
	{
		if (!class_exists($dynamicTypeName))
		{

			// write
			$code = "class ".$dynamicTypeName.' extends '.$objType.'{'.CRLF;
			$code .= 'var $Handler;'.CRLF;
			for($i=0;$i<count($methods);$i++)
			{
				$code .= 'function '.$methods[$i].'()'.CRLF;
				$code .= '{'.CRLF;
				$code .= '$paraments = func_get_args();'.CRLF;
				$code .= 'return $this->Handler->Invoke(&$this->Handler->object, "'.$methods[$i].'", $paraments);'.CRLF;
				$code .= '}'.CRLF;
			}
			$code .= '}'.CRLF;

			eval($code);		
		}
		
		$clazz = new $dynamicTypeName;
		$clazz->Handler = $handler;
		return $clazz;
	}
}


?>